package org.runecore.rs2.model.mask;

import java.util.BitSet;
import java.util.LinkedList;
import java.util.List;

import org.runecore.rs2.model.Entity;
import org.runecore.rs2.model.player.Player;

/**
 * RuneCore
 * Sep 16, 2011
 * @author Harry Andreas<Harry@RuneCore.org>
 */
public class EntityMask {
	
	/**
	 * A <code>BitSet</code> of update flags
	 */
	private final BitSet updateFlags = new BitSet();
	
	/**
	 * A <code>Movement</code> instance for the entity
	 */
	private Movement movementManager;
	
	/**
	 * A <code>Boolean</code> to see if
	 * an update is required
	 * @return <code>Boolean</code> if an updated is needed
	 */
	public boolean updateNeeded() {
		return !updateFlags.isEmpty();
	}
	
	/**
	 * The <code>Animation</code> instance for
	 * the <code>EntityMask</code>
	 */
	private Animation animationMask;
	
	/**
	 * The <code>List</code> of <code>Player</code>'s
	 * in the region
	 */
	private List<Player> regionPlayers;
	
	/**
	 * Constructor
	 */
	public EntityMask(Entity e) {
		setRegionPlayers(new LinkedList<Player>());
		setMovementManager(new Movement(e));
	}
	
	/**
	 * Flag's the update
	 * @param flag
	 */
	public void flag(UpdateFlag flag) {
		getUpdateFlags().set(flag.ordinal(), Boolean.TRUE);
	}
	
	/**
	 * Reset's the <code>Entity</code>'s masks
	 */
	public void reset() {
		getUpdateFlags().clear();
	}

	/**
	 * @param animationMask the animationMask to set
	 */
	public void setAnimationMask(Animation animationMask) {
		this.animationMask = animationMask;
	}

	/**
	 * @return the animationMask
	 */
	public Animation getAnimationMask() {
		return animationMask;
	}

	/**
	 * @param regionPlayers the regionPlayers to set
	 */
	public void setRegionPlayers(List<Player> regionPlayers) {
		this.regionPlayers = regionPlayers;
	}

	/**
	 * @return the regionPlayers
	 */
	public List<Player> getRegionPlayers() {
		return regionPlayers;
	}

	/**
	 * @return the updateFlags
	 */
	public BitSet getUpdateFlags() {
		return updateFlags;
	}

	/**
	 * @return the movementManager
	 */
	public Movement getMovementManager() {
		return movementManager;
	}

	/**
	 * @param movementManager the movementManager to set
	 */
	public void setMovementManager(Movement movementManager) {
		this.movementManager = movementManager;
	}
	

}